<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>文件共享服务</title>
<link rel="stylesheet" type="text/css" th:href="@{/css/index.css}"></link>
<script type="text/javascript" th:src="@{/js/jquery-3.7.1.min.js}"></script>
<style type="text/css">
.login {
	border: 1px solid black;
	border-radius: 10px;
	width: 600px;
	max-width: calc(100% - 10px);
	margin: 10vh auto;
	padding: 5px;
}
.login input {
	font-size: 20px;
	width: 80%;
	margin: 20px 10%;
	height: 40px;
	box-sizing: border-box;
}
.login button {
	font-size: 20px;
	height: 40px;
	width: 80%;
	margin: 20px 10%;
}
h2 {
	text-align: center;
}
</style>
</head>
<body>
<div class="login">
<h2>请输入校验码</h2>
<input class="code" />
<button onclick="check()">校    验</button>
</div>
<script type="text/javascript">
function check() {
	const code = $(".code").val();
	if (!code) {
		alert("请输入验证码!");
		return;
	}
	
	$.ajax({
		url: "/auth/code",
		type: "POST",
		data: "code="+code,
		processData: false,
		success: data => {
			if (data.success) {
				window.location.href="/file/home";
			} else {
				alert(data.errmsg);
			}
		},
		error: () => {
			alert("server error");
		}
	});
}
</script>
</body>
</html>
